package state;

import lombok.AllArgsConstructor;

/**
 * 发放奖品的状态
 */
@AllArgsConstructor
public class DispenseState implements State {
    private final RaffleActivity activity;

    /**
     * 扣除积分
     */
    @Override
    public void deductPoints(int points) {
        System.out.println("不能扣除积分！");
    }

    /**
     * 是否抽中奖品
     */
    @Override
    public boolean raffle() {
        System.out.println("不能抽奖！");
        return false;
    }

    /**
     * 发放奖品 如果奖品还有剩余，则将状态设置为不能抽奖，否则设置为奖品领完
     */
    @Override
    public void dispensePrize() {
        if (activity.getCount() > 0) {
            System.out.println("恭喜中奖！");
            activity.setState(activity.getNoRaffleState());
        } else {
            System.out.println("很遗憾，奖品发送完了！");
            activity.setState(activity.getDispenseOutState());
        }
    }
}
